#include<iostream>
using namespace std;
class Pet;
class CDate
{
    private:
        int year,month,day;
    public:
        int alldays;
        CDate(int _y,int _m,int _d)
        {
            year=_y;
            month=_m;
            day=_d;
            SetAlldays();
        }
        bool IsLeap(int i)
        {
            return ((i % 4 == 0) && (i % 100 != 0)) || (i % 400 == 0);
        }
        void SetAlldays()
        {
            alldays = 0;
            int mon[] = { 31,28,31,30,31,30,31,31,30,31,30,31 };
            for (int i = 1900; i < year; ++i)
            {
                if (IsLeap(i))
                    alldays += 366;
                else
                    alldays += 365;
            }
            if (IsLeap(year))
            {
                mon[1]++;
            }
            for (int i = 0; i < month - 1 ; ++i)
            {
                alldays += mon[i];
            }
            alldays += day;
        }
        friend Pet;
};
class Pet
{
    protected:
        string name;//姓名
        float length;//身长
        float weight;//体重
        CDate current;//开始记录时间
    public:
        Pet(int _y,int _m,int _d,string na,float le,float we):current(_y,_m,_d)
        {
            name=na;
            length=le;
            weight=we;
        }
        virtual void display(CDate day)=0;//输出目标日期时宠物的身长和体重
};
class Cat:public Pet
{
    public:
        Cat(int _y,int _m,int _d,string na,float le,float we):Pet(_y,_m,_d,na,le,we){}
        void display(CDate day)
        {
            if(day.alldays<current.alldays)
            {
                cout<<"error"<<endl;
                return;
            }
            int dayleft=day.alldays-current.alldays;
            for(int i=0;i<dayleft;++i)
            {
                length+=0.1;
                weight+=0.2;
            }
            cout<<name<<" after "<<dayleft<<" day: ";
            printf("length=%.2f,weight=%.2f\n",length,weight);
        }
};
class Dog:public Pet
{
    public:
        Dog(int _y,int _m,int _d,string na,float le,float we):Pet(_y,_m,_d,na,le,we){}
        void display(CDate day)
        {
            if(day.alldays<current.alldays)
            {
                cout<<"error"<<endl;
                return;
            }
            int dayleft=day.alldays-current.alldays;
            for(int i=0;i<dayleft;++i)
            {
                length+=0.2;
                weight+=0.1;
            }
            cout<<name<<" after "<<dayleft<<" day: ";
            printf("length=%.2f,weight=%.2f\n",length,weight);
        }
};
int main()
{
    int t;
    cin>>t;
    int sy,sm,sd;
    cin>>sy>>sm>>sd;
    while(t--)
    {
        int tag,cy,cm,cd;
        string name;
        float length,weight;
        cin>>tag>>name>>length>>weight>>cy>>cm>>cd;
        CDate check(cy,cm,cd);
        Pet* point;
        if(tag==1)
        {
            point=new Cat(sy,sm,sd,name,length,weight);
            point->display(check);
            delete point;
        }
        else
        {
            point=new Dog(sy,sm,sd,name,length,weight);
            point->display(check);
            delete point;
        }
    }
}